<%@ page pageEncoding="UTF-8"%>
<%@ page import="java.util.*"%>
<%@ page import="com.hwhp.entity.*"%>
<%@ page import="com.hwhp.service.console.DepartService,com.hwhp.service.console.impl.DepartServiceImpl" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
		DepartService departService = new DepartServiceImpl();
%>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>部门管理</title>
		<LINK href="<%=basePath%>css/milkwhite.css" type=TEXT/CSS
			rel=StyleSheet></LINK>
		<LINK href="<%=basePath%>css/htmilkwhite.css" type=TEXT/CSS
			rel=StyleSheet></LINK>
		<script type="text/javascript">
			var basepath='<%=basePath%>';
	    </script>
		<script type="text/javascript"
			src="<%=basePath%>/js/tree/xtree/xloadtree/json.js"></script>
		<script type="text/javascript"
			src="<%=basePath%>/js/tree/xtree/xloadtree/xtree.js"></script>
		<script type="text/javascript"
			src="<%=basePath%>/js/tree/xtree/xloadtree/xmlextras.js"></script>
		<script type="text/javascript"
			src="<%=basePath%>js/tree/xtree/xloadtree/xloadtree.js"></script>
	</head>
	<body style="MARGIN: 0px;" onunload="init()" id="body">
		<TABLE cellSpacing=10 width="100%" height="100%">
			<TBODY>
				<TR>
					<TD class=contenttab1 vAlign=top>
						<script type="text/javascript">
				         var orgTree = new WebFXTree("组织机构");
				<%
				String action="";
				 //选择树初始化参数
				int itype=0;//type=0 无选择　type=1　复选框　type=2　单选框
				List<Deptment> list=(List<Deptment> )request.getAttribute("deptList");
						if(list!=null&&list.size()>0){
						  for(Deptment dept:list){
						    String src=basePath+"html/manager/deptment/departManagerSubTree.jsp";
						    String deptid=dept.getDeptId();
						    String deptname=dept.getDeptName();
						    List<Deptment> subList=departService.getChildDepts(deptid);
						    if(subList!=null&&subList.size()>0){
						      src=src+"?deptid="+deptid;
						      action="javascript:doSelect('"+deptid+"')";
						    }else{
						      src="";
						      action="javascript:doSelect('"+deptid+"')";
						    }
				%>
				var currentTree =  orgTree.add(new WebFXLoadTreeItem("<%=deptname%>","<%=src%>","<%=action%>",null,null,null,"<%=itype%>","<%=deptid%>"));
				<%
				   }
				   System.out.println("terfdfafasdfas");
				   }
				%>
				document.write(orgTree);
				</script>
					</TD>
				</TR>
			</TBODY>
		</TABLE>
	</body>
	<script type="text/javascript">
	  function doSelect(deptid){
	  //alert("fasdfsafa");
	  parent.doRefresh(deptid);
	  }
	</script>
</html>
